﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using nMongo.Tests.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MongoDB.Driver.Linq;

namespace nMongo.Tests.Repository
{
    [TestClass]
    public partial class MongoRepositoryTests
    {
        [TestMethod]
        public void ConstructorFirstOverload()
        {
            MongoEngine engine = new MongoEngine(TestsConfiguration.ConnectionString, TestsConfiguration.DatabaseName);
            MongoRepository<User> users = new MongoRepository<User>(engine);

            // Assert
            Assert.AreEqual(engine.ConnectionString, users.Connection.ConnectionString);
            Assert.AreEqual(engine.Database.Name, users.Connection.Database.Name);
            Assert.AreEqual(engine.GetCollection<User>().AsQueryable().Count(), users.CollectionQuery.Count());
        }

        [TestMethod]
        public void ConstructorSecondOverload()
        {
            MongoRepository<User> users = new MongoRepository<User>(TestsConfiguration.ConnectionString, TestsConfiguration.DatabaseName);

            // Assert
            Assert.AreEqual(TestsConfiguration.ConnectionString, users.Connection.ConnectionString);
            Assert.AreEqual(TestsConfiguration.DatabaseName, users.Connection.Database.Name);
        }
    }
}
